package com.account.controller;

import com.account.domain.TAccount;
import com.account.order.service.impl.TAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import spring.cloud.Utils.R;

import java.util.List;

/**
 * @author cyt
 * @create 2020-06-07 10:42
 */

@RequestMapping("/account")
@Slf4j
@RestController
public class TestController {

    @Autowired
    TAccountService tAccountService;

    /**
     * 测试
     * @return
     */
    @RequestMapping("/getAll")
    public R getall() {
        List<TAccount> all = tAccountService.getAll();
        return R.ok().data("ALL", all);
    }

    /**
     * 修改账户
     * @param userId
     * @param num
     * @return
     */
    @RequestMapping("/dec/{userId}/{num}")
    public R dec(@PathVariable("userId") Integer userId, @PathVariable("num") Integer num) {
        log.info("userId" + userId);
        tAccountService.dec(userId, num);
        return R.ok();
    }

}
